home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 2 / Deutsche Edition 2.iso / mac / POWERMAC / C64 / SOURCE / Instructions68K.h < prev    next >
Text File  |  1994-06-06  |  6KB  |  302 lines

  1. #define    PC(x)                            \
  2.     ADDQ.W        x,rPC
  3.  
  4. #define    NegSet(z)                        \
  5.     BTST        #7,z                    \
  6.     BEQ            @99                        \
  7.     BSET        #bNEG,rFLAGS            \
  8. @99
  9.  
  10. #define    FlagsNZ(z)                        \
  11.     MOVE.B        z,D0                    \
  12.     BSR            doFlagsNZ
  13.  
  14. #define ORA(x)                             \
  15.     x(D1)                                \
  16.     ByteAt(D1,D1)                        \
  17.     OR.B        D1,rA                    \
  18.     FlagsNZ(rA)
  19.  
  20. #define ASL(x)                             \
  21.     x(D1)                                \
  22.     ByteAt(D1,D0)                        \
  23.     ANDI.B        #0xff-(CAR|NEG|ZER),rFLAGS    \
  24.     BTST        #7,D0                    \
  25.     BEQ            @3                        \
  26.     BSET        #bCAR,rFLAGS            \
  27. @3    LSL.B        #1,D0                    \
  28.     MOVE.B        D0,(rRAM,D1.L)            \
  29.     NegSet(D0)                            \
  30.     TST.B        D0                        \
  31.     BNE            @4                        \
  32.     BSET        #bZER,rFLAGS            \
  33. @4
  34.  
  35. #define LSR(x)                            \
  36.     x(D1)                                \
  37.     ByteAt(D1,D0)                        \
  38.     ANDI.B        #0xff-(CAR|NEG|ZER),rFLAGS    \
  39.     BTST        #0,D0                    \
  40.     BEQ            @3                        \
  41.     BSET        #bCAR,rFLAGS            \
  42. @3    LSR.B        #1,D0                    \
  43.     BNE            @4                        \
  44.     BSET        #bZER,rFLAGS            \
  45. @4    MOVE.B        D0,(rRAM,D1.L)
  46.  
  47. #define BCL(x)                             \
  48.     BTST        x,rFLAGS                \
  49.     BEQ            @3                        \
  50.     ADDQ.W        #1,rPC                    \
  51.     RTS                                    \
  52. @3    ImmediateByte(D1)                    \
  53.     ADDQ.W        #1,rPC                    \
  54.     BTST        #7,D1                    \
  55.     BNE            @4                        \
  56.     ADD.W        D1,rPC                    \
  57.     RTS                                    \
  58. @4    EORI.W        #0xFF,D1                \
  59.     ADD.W        #1,D1                    \
  60.     SUB.W        D1,rPC
  61.  
  62. #define BST(x)                             \
  63.     BTST        x,rFLAGS                \
  64.     BNE            @3                        \
  65.     ADDQ.W        #1,rPC                    \
  66.     RTS                                    \
  67. @3    ImmediateByte(D1)                    \
  68.     ADDQ.W        #1,rPC                    \
  69.     BTST        #7,D1                    \
  70.     BNE            @4                        \
  71.     ADD.W        D1,rPC                    \
  72.     RTS                                    \
  73. @4    EORI.W        #0xFF,D1                \
  74.     ADD.W        #1,D1                    \
  75.     SUB.W        D1,rPC
  76.  
  77. #define CLR(x)                             \
  78.     BCLR        x,rFLAGS
  79.     /*flags &=~x; return*/
  80.  
  81. #define SET(x)                             \
  82.     BSET        x,rFLAGS
  83.     /*flags |= x; return*/
  84.  
  85. #define AND(x)                             \
  86.     x(D1)                                \
  87.     ByteAt(D1,D0)                        \
  88.     AND.B    D0,rA                        \
  89.     FlagsNZ(rA)
  90.     /*a &= ByteAt(x()); FlagsNZ(a)*/
  91.  
  92. #define BIT(x)                             \
  93.     x(D1)                                \
  94.     ByteAt(D1,D1)                        \
  95.     ANDI.B        #0xFF-(ZER|NEG|OVF),rFLAGS    \
  96.     MOVE.B        rA,D0                    \
  97.     AND.B        D1,D0                    \
  98.     BNE            @3                        \
  99.     BSET        #bZER,rFLAGS            \
  100. @3    ANDI.B        #(NEG|OVF),D1            \
  101.     OR.B        D1,rFLAGS
  102.  
  103. #define ROL(x)                             \
  104.     x(D1)                                \
  105.     ByteAt(D1,D0)                        \
  106.     BTST        #bCAR,rFLAGS            \
  107.     BEQ            @3                        \
  108.     BTST        #7,D0                    \
  109.     BNE            @4                        \
  110.     BCLR        #bCAR,rFLAGS            \
  111. @4    LSL.B        #1,D0                    \
  112.     OR.B        #1,D0                    \
  113.     BRA            @5                        \
  114. @3    BTST        #7,D0                    \
  115.     BEQ            @6                        \
  116.     BSET        #bCAR,rFLAGS            \
  117. @6    LSL.B        #1,D0                    \
  118. @5    MOVE.B        D0,(rRAM,D1.L)            \
  119.     FlagsNZ(D0)
  120.  
  121. #define ROR(x)                             \
  122.     x(D1)                                \
  123.     ByteAt(D1,D0)                        \
  124.     BTST        #bCAR,rFLAGS            \
  125.     BEQ            @3                        \
  126.     BTST        #0,D0                    \
  127.     BNE            @4                        \
  128.     BCLR        #bCAR,rFLAGS            \
  129. @4    LSR.B        #1,D0                    \
  130.     OR.B        #0x80,D0                \
  131.     BRA            @5                        \
  132. @3    BTST        #0,D0                    \
  133.     BEQ            @6                        \
  134.     BSET        #bCAR,rFLAGS            \
  135. @6    LSR.B        #1,D0                    \
  136. @5    MOVE.B        D0,(rRAM,D1.L)            \
  137.     FlagsNZ(D0)
  138.  
  139. #define EOR(x)                            \
  140.     x(D1)                                \
  141.     ByteAt(D1,D1)                        \
  142.     EOR.B        D1,rA                    \
  143.     FlagsNZ(rA)
  144.     /*a^=ByteAt(x());FlagsNZ(a)*/
  145.  
  146. #define STA(y)                            \
  147.     y(D1)                                \
  148.     MOVE.B        rA,(rRAM,D1.L)
  149.     /*RAM[x()]=a*/
  150.  
  151. #define STY(x)                            \
  152.     x(D1)                                \
  153.     MOVE.B        rY,(rRAM,D1.L)
  154.     /*RAM[x()]=y*/
  155.  
  156. #define STX(y)                            \
  157.     y(D1)                                \
  158.     MOVE.B        rX,(rRAM,D1.L)
  159.     /*RAM[y()]=x*/
  160.  
  161. #define LDA(x)                            \
  162.     x(D1)                                \
  163.     ByteAt(D1,rA)                        \
  164.     FlagsNZ(rA)
  165.     /*a=ByteAt(x()); FlagsNZ(a)*/
  166.  
  167. #define LDY(x)                            \
  168.     x(D1)                                \
  169.     ByteAt(D1,rY)                        \
  170.     FlagsNZ(rY)
  171.     /*y=ByteAt(x()); FlagsNZ(y)*/
  172.  
  173. #define LDX(y)                            \
  174.     y(D1)                                \
  175.     ByteAt(D1,rX)                        \
  176.     FlagsNZ(rX)
  177.     /*x=ByteAt(y()); FlagsNZ(x)*/
  178.  
  179. #define BCD2DEC(x)                        \
  180.     LEA        bcd2dec,A2                    \
  181.     MOVE.B    (A2,x.W),x                    \
  182.     ANDI.W    #0x00FF,x
  183.     /*((x&15)+((x&240)>>4)*10)*/
  184.  
  185. #define DEC2BCD(x,y)                    \
  186.     LEA        dec2bcd,A2                    \
  187.     MOVE.B    (A2,x.W),y                    \
  188.     ANDI.W    #0x00FF,y
  189.     /*{ y=x/10; x -=y*10; y=(y<<4) +x;}*/
  190.  
  191. #define    ADC(x)                            \
  192.         x(D1)                            \
  193.         ByteAt(D1,D1)                    \
  194.         ANDI.W    #0x00FF,D1                \
  195.         BTST    #bDEC,rFLAGS            \
  196.         BNE        @3                        \
  197.         ANDI.W    #0x00FF,rA                \
  198.         ADD.W    D1,rA                    \
  199.         BTST    #bCAR,rFLAGS            \
  200.         BEQ        @7                        \
  201.         ADDQ.W    #1,rA                    \
  202. @7        ANDI.B    #0xFF-(CAR|OVF|NEG|ZER),rFLAGS    \
  203.         CMPI.W    #0x00FF,rA                \
  204.         BLE        @8                        \
  205.         OR.B    #(OVF|CAR),rFLAGS        \
  206. @8        FlagsNZ(rA)                        \
  207.         BRA        @6                        \
  208. @3        BCD2DEC(D1)                        \
  209.         BCD2DEC(rA)                        \
  210.         ADD.W    D1,rA                    \
  211.         BTST    #bCAR,rFLAGS            \
  212.         BEQ        @4                        \
  213.         ADDQ.W    #1,rA                    \
  214. @4        ANDI.B    #0xFF-(CAR|OVF|NEG|ZER),rFLAGS    \
  215.         CMPI.W    #99,rA                    \
  216.         BLE        @5                        \
  217.         OR.B    #(CAR|OVF),rFLAGS        \
  218.         SUBI.W    #100,rA                    \
  219. @5        FlagsNZ(rA)                        \
  220.         DEC2BCD(rA,rA)                    \
  221. @6
  222.  
  223. #define    SBC(x)                            \
  224.         x(D1)                            \
  225.         ByteAt(D1,D1)                    \
  226.         ANDI.W    #0x00FF,D1                \
  227.         BTST    #bDEC,rFLAGS            \
  228.         BNE        @3                        \
  229.         ANDI.W    #0x00FF,rA                \
  230.         SUB.W    D1,rA                    \
  231.         BTST    #bCAR,rFLAGS            \
  232.         BNE        @7                        \
  233.         SUB.W    #1,rA                    \
  234. @7        ANDI.B    #0xFF-(CAR|OVF|NEG|ZER),rFLAGS    \
  235.         TST.W    rA                        \
  236.         BNE        @8                        \
  237.         OR.B    #(ZER|CAR),rFLAGS        \
  238.         BRA        @9                        \
  239. @8        BMI        @10                        \
  240.         BSET    #bCAR,rFLAGS            \
  241.         BRA        @9                        \
  242. @10        BSET    #bOVF,rFLAGS            \
  243. @9        NegSet(rA)                        \
  244.         BRA        @6                        \
  245. @3        BCD2DEC(D1)                        \
  246.         BCD2DEC(rA)                        \
  247.         SUB.W    D1,rA                    \
  248.         BTST    #bCAR,rFLAGS            \
  249.         BNE        @4                        \
  250.         SUB.W    #1,rA                    \
  251. @4        ANDI.B    #0xFF-(CAR|OVF|NEG|ZER),rFLAGS    \
  252.         TST.W    rA                        \
  253.         BNE        @5                        \
  254.         OR.B    #(ZER|CAR),rFLAGS        \
  255.         BRA        @11                        \
  256. @5        BMI        @12                        \
  257.         BSET    #bCAR,rFLAGS            \
  258.         BRA        @11                        \
  259. @12        BSET    #bNEG,rFLAGS            \
  260.         ADDI.W    #100,rA                    \
  261. @11        DEC2BCD(rA,rA)                    \
  262. @6
  263.  
  264. #define    DECR(x)                            \
  265.     x(D1)                                \
  266.     ByteAt(D1,D0)                        \
  267.     SUBQ.B    #1,D0                        \
  268.     MOVE.B    D0,(rRAM,D1.L)                \
  269.     FlagsNZ(D0)
  270.  
  271. #define    INCR(x)                            \
  272.     x(D1)                                \
  273.     ByteAt(D1,D0)                        \
  274.     ADDQ.B    #1,D0                        \
  275.     MOVE.B    D0,(rRAM,D1.L)                \
  276.     FlagsNZ(D0)
  277.  
  278. #define    CPY(mode)    CP(mode,rY)
  279. #define    CPX(mode)    CP(mode,rX)
  280. #define    CMP(mode)    CP(mode,rA)
  281.  
  282. #define    CP(mode,reg)                        \
  283.         mode(D1)                            \
  284.         ByteAt(D1,D1)                        \
  285.         DOCP(reg)
  286.  
  287. #define    CPI(reg)                            \
  288.         ImmediateByte(D1)                    \
  289.         DOCP(reg)
  290.  
  291. #define    DOCP(reg)                            \
  292.         ANDI.B    #0xFF-(CAR|ZER|NEG),rFLAGS    \
  293.         CMP.B    reg,D1                        \
  294.         BNE        @3                            \
  295.         ORI.B    #(CAR|ZER),rFLAGS            \
  296.         BRA        @4                            \
  297. @3:        BCC        @5                            \
  298.         BSET    #bCAR,rFLAGS                \
  299.         BRA        @4                            \
  300. @5:        BSET    #bNEG,rFLAGS                \
  301. @4
  302.